    <!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>个人信息</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <!--weui.min.css-->
    <link rel="stylesheet" href="/static/index/css/page/base.css"/>
    <link rel="stylesheet" href="/static/index/css/page/font.css"/>
    <link rel="stylesheet" href="/static/index/jquery_weui/css/swiper.min.css"/>
    <link rel="stylesheet" type="text/css" href="/static/index/jquery_weui/lib/weui.min.css">
    <!--jquery-weui.min.css-->
    <link rel="stylesheet" type="text/css" href="/static/index/jquery_weui/css/jquery-weui.min.css">
    <link rel="stylesheet" href="/static/index/css/page/personal.css" />
</head>
<style>
    .renz-pic
    {

    }


    /*上传input*/
    .myUpload
    {
        position: absolute;
        opacity: 0;
        z-index: 100;
        width: 30%;
        height: 13%;
        display: block;
    }
    /*关闭按钮*/
    .close
    {
        position: absolute;
        right: 0;
        top: 0;
        width: 20px;
        height: 20px;
        z-index: 200;
        cursor: pointer;
    }
    /*隐藏*/
    .hideimg
    {
        display: none;
    }
    /*上传的图片*/
    .addimg
    {
        width: 100%;
        height: 100%;
    }
    /*显示上传的图片*/
    .showimg
    {
        width: 100%;
        height: 100%;
    }
    #dtxz{
        width: 6rem;
        height: 4rem;
        float: left;
        margin: 4% auto;
    }
    .submit{
        float: left;
    }
    .shili{
	  position: absolute;
	  left: 4%;
	  top: 68%;
    }
    .rz_submit{
    	height:1.7rem;
    	background:none;
    	border:0;
    	font-size: 14px;
    	color: #FFFFFF;
    }
    .fileInputContainer{
        height:80px;
        background:url(/static/index/img/pic2.png) no-repeat;
        position:relative;
        left: -1rem;
        width: 80px;
    }
    .fileInputtwo{
        height:80px;
        background:url(/static/index/img/pic1.png) no-repeat;
        position:relative;
       
        width: 85px;
    }
    .fileInput{
        height:4rem;
        width:4rem;
        overflow: hidden;
        font-size: 300px;
        position:absolute;
        right:0;
        top:0;
        opacity: 0;
        filter:alpha(opacity=0);
        cursor:pointer;
    }
    .personal_img2{
        height:126px;
        width:100%;
    }
    .phone-title{
    	position: relative;
    	left: 1rem;
    }
    .personal-list{
    	width: 100%;
    }
    .pageControl{
    	min-height:100% ;
    	width: 100%;
    }
    .min{
    	width: 100%;
    	height: 100%;
    }
</style>

<body>
<div class="pageControl personal bg-f5">
    <!--主体-->
    
    <div class="main">
        <div class="bg-di"></div>
        <div class="msui_nav msui_navTop">
            <a class="msui_navTop-back" href="javascript:history.back();"><i class="micon-back"></i></a>
            <h1 class="msui_navTop-title">个人信息</h1>
        </div>
        <div class="top">
            <a class="zhe"></a>
            <!--背景图片-->
            {if $info.user_back}
            <img src="{$info.user_back}" alt=""/>
            {else}
            <img src="/static/index/img/idx.png" alt=""/>
            {/if}
            <div class="index-top-tab">
                <div id="personal-bg"></div>
                <div class="personal_img">
                	{if $info.img}
                    <a><img class="personal_img1" src="{$info.img}" alt=""/></a>
                    {else}
                    <a><img class="personal_img1" src="/static/index/img/head.png" alt=""/></a>
                    {/if}
                    <a id="personal-tou" href=""><img src="/static/index/img/p1.png" alt=""/></a>
                </div>
                <p class="bg-ff7 renZh">
                    {if $vo.is_rz eq 1}<img src="/static/index/img/x0.png" alt=""/>{/if}
                    <span>{if $info.is_rz eq 0}未认证{elseif $info.is_rz eq 2}待审核{else}已认证{/if}</span>
                </p>
                <div class="index-tab">
                </div>
            </div>
        </div>
        
        <div class="personal-list">
            <!--切换class为active1换目录-->
            <div class="personal-list1 active1" data-value="1">
                <div class="weui-cells">
                    <div class="weui-cell weui-cell_access">
                        <div class="weui-label">
                            <img src="/static/index/img/p2.png" alt=""/>
                            <span>昵称</span>
                        </div>
                        <div class="weui-cell__bd">
                            <input type="text" id="uname" class="weui-input"  value="{$info.name}"/>
                        </div>
                        <div class="">

                        </div>
                    </div>
                    <div class="weui-cell weui-cell_access">
                        <div class="weui-label">
                            <img src="/static/index/img/p3.png" alt=""/>
                            <span>性别</span>
                        </div>
                        <div class="weui-cell__bd">
                            <input id="sex" type="text" class="weui-input" value="{if $user_id}{if $info.sex eq 0}女{elseif $info.sex eq 1}男{else}未选择{/if}{/if}"/>
                        </div>
                        {if $info.sex eq -1}
                        	<div class="weui-icon-warn"></div>
                        {else}
                        	<div class=""></div>
                        {/if}
                    </div>
                    <div class="weui-cell weui-cell_access">
                        <div class="weui-label">
                            <img src="/static/index/img/p4.png" alt=""/>
                            <span>年龄</span>
                        </div>
                        <div class="weui-cell__bd">
                            <input type="text" id="age" class="weui-input" value="{$info.age}"/>
                        </div>
                        <div class="">

                        </div>
                    </div>
                </div>
                <div class="weui-cells bang">
                	{if $info['tel']}
	                    <a class="weui-cell weui-cell_access">
	                        <div class="weui-cell__bd">
	                            <img src="/static/index/img/p5.png" alt=""/>
	                            <span>手机号绑定</span>
	                        </div>
	                        <p class="cl-3333">已绑定</p>
	                        <div class="weui-icon-success-no-circle"></div>
	                    </a>
                    {else}
	                    <a id="personal-phone" class="weui-cell weui-cell_access">
	                        <div class="weui-cell__bd">
	                            <img src="/static/index/img/p5.png" alt=""/>
	                            <span>手机号绑定</span>
	                        </div>
	                        <p class="cl-3333">未绑定</p>
	                        <div class="weui-icon-warn"></div>
	                    </a>
                    {/if}
                    {if $info['email'] eq ''}
                    <a id="personal-email" class="weui-cell weui-cell_access">
                        <div class="weui-cell__bd">
                            <img src="/static/index/img/p6.png" alt=""/>
                            <span>邮箱绑定</span>
                        </div>
                        <div class="weui-cell__ft">
                            <p class="cl-3333">未绑定</p>
                        </div>
                    </a>
                    {else}
                    <a class="weui-cell weui-cell_access">
                        <div class="weui-cell__bd">
                            <img src="/static/index/img/p6.png" alt=""/>
                            <span>邮箱绑定</span>
                        </div>
                        <div class="weui-cell__ft">
                            <p class="cl-3333">已绑定</p>
                        </div>
                    </a>
                    {/if}
                    {if $info['is_rz'] eq 0}
	                    <a class="weui-cell weui-cell_access" id="shiren">
	                        <div class="weui-cell__bd">
	                            <img src="/static/index/img/p7.png" alt=""/>
	                            <span>用户实名认证</span>
	                        </div>
	                        <div class="weui-cell__ft">
	                            <p class="cl-3333">未实名</p>
	                        </div>
	                    </a>
                    {elseif $info['is_rz'] eq 1}
	                    <a class="weui-cell weui-cell_access">
	                        <div class="weui-cell__bd">
	                            <img src="/static/index/img/p7.png" alt=""/>
	                            <span>用户实名认证</span>
	                        </div>
	                        <div class="weui-cell__ft">
	                            <p class="cl-3333">已实名</p>
	                        </div>
	                    </a>
                    {else}
	                    <a class="weui-cell weui-cell_access">
	                        <div class="weui-cell__bd">
	                            <img src="/static/index/img/p7.png" alt=""/>
	                            <span>用户实名认证</span>
	                        </div>
	                        <div class="weui-cell__ft">
	                            <p class="cl-3333">待审核</p>
	                        </div>
	                    </a>
                    {/if}
                    <div class="weui-cell weui-cell_access">
                        <div class="weui-label">
                            <img src="/static/index/img/p2.png" alt=""/>
                            <span>签名</span>
                        </div>
                        <div class="weui-cell__bd">
                            <input type="text" id="qianmin" class="weui-input" value="{$info.sign}"/>
                            <input type="hidden" id="uid" class="weui-input" value="{$info.id}"/>
                        </div>
                        <div class="weui-cell__ft">

                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!--实名认证弹窗,加class为active3显示弹出-->
    <div class="shiren">
        <p>听说</p>
        <p>通过了实名认证的用户</p>
        <p>会有更多人愿意加您哟~</p>
        <div class="pic-btn">
            <p><a class="bg-b3 cl-f shiren-qu" href="">取消</a></p>
            <p> <a class="bg-ff7 cl-f shiren-go" href="">前去实名认证</a></p>
        </div>
    </div>
    <!--实名认证窗口-->
    <div id="renzheng" class="">
        <!--<form action="/index/personal/realname" method="post" enctype="multipart/form-data">-->
        <div class="weui-cell weui-cell_access">
            <div class="weui-label">
                <img src="/static/index/img/r1.png" alt=""/>
            </div>
            <div class="weui-cell__bd">
                <span>真实姓名:</span>
                <input type="text" id="name" class="weui-input"/>
            </div>
            <div class="weui-cell__ft">

            </div>
        </div>
        <div class="weui-cell weui-cell_access">
            <div class="weui-label">
                <img src="/static/index/img/r2.png" alt=""/>

            </div>
            <div class="weui-cell__bd">
                <span>身份证号码:</span>
                <input type="text" id="IDcard" class="weui-input w40"/>
            </div>
            <div class="weui-cell__ft">

            </div>
        </div>
        <div class="weui-cell weui-cell_access hang-last">
            <div class="weui-label">
                <img src="/static/index/img/r3.png" alt=""/>
            </div>
            <div class="weui-cell__bd">
                <span class="renz-pic-txt">身份证反面:</span>
            </div>
            <div class="weui-cell__ft">

            </div>
        </div>
        <div class="renz-pic">
            <a class="sctp">
            	<div>示例：</div>
                <!--<input type="hidden" id="number" class="hiddens" name="number" value="">
                <input type="file" name="pic1" id="file" class="myUpload" />-->
                <!--<img src="/static/index/img/1.jpg" class="close hideimg"/>-->
                <img src="/static/index/img/shili.jpg" class="addimg"/>
                <!--<img class="showimg hideimg"/>-->
            </a>
            <a class="sctp">
                <input type="hidden" id="number" class="hiddens" name="number" value="">
                <input type="file" name="pic2" id="file" class="myUpload" />
                <input type="hidden" id="photo" value=""/>
               <!-- <img src="/static/index/img/1.jpg" class="close hideimg"/>-->
                <img src="/static/index/img/card.png" class="addimg"/>
                <img class="showimg hideimg"/>
            </a>
            
        </div>
        <div>
            <p class="renz-txt1">注: 以上信息必须确认为真实有效  &nbsp;实名认证具有法律效应</p>
            <p class="renz-txt2">本公司将尊重个人隐私  &nbsp;并保留最终解释权</p>
        </div>
        <div class="pic-btn">
            <p><a id="renzheng-qu" class=" bg-b3 cl-f" href="">取消</a></p>
            <p><a class="bg-ff7 cl-f" id="user_rz" href="javascript:;">上传</a></p>
        </div>
           <!-- <input type="hidden" name="id" value="{$user_id}"/>
        </form>-->
    </div>
    <!--编辑邮箱窗口-->
    <div class="personal-email tan">
        <div class="bg-tan"></div>
        <div class="msui_nav msui_navTop">
            <a class="msui_navTop-back goBack" href="javascript:history.back();"><i class="micon-back"></i></a>
            <h1 class="msui_navTop-title">绑定邮箱</h1>
        </div>
        <div class="email-input">
            <div class="personal-input">
                <div class="email-label">
                    <label class="fs08">输入邮箱号：</label>
                </div>
                <div class="weui-cell__bd">
                    <input type="text" class="weui-input" id="email_num"/>
                </div>
            </div>
            <a id="binding_email" class="personal-btn mt30 cl-f">发送验证到您的邮箱</a>
            <!--<div class="pic-btn">
                <p><a class="bg-b3 cl-f tan-qu" href="">取消</a></p>
                <p> <a class="bg-ff7 cl-f" href="">确定</a></p>
            </div>-->
        </div>
    </div>
    <!--编辑手机号码窗口-->
    <div class="personal-phone tan">
        <div class="bg-tan"></div>
        <div class="msui_nav msui_navTop">
            <a class="msui_navTop-back goBack" href="javascript:history.back();"><i class="micon-back"></i></a>
            <h1 class="msui_navTop-title">绑定手机</h1>
        </div>
        <div class="email-input">
            <div class="personal-input">
                <div class="email-label">
                    <label class="fs08">输入手机号：</label>
                </div>
                <div class="weui-cell__bd">
                    <input type="text" class="weui-input" id="tel"/>
                </div>
            </div>
            <div class="personal-input">
                <div class="email-label">
                    <label class="fs08">输入验证码：</label>
                </div>
                <div class="weui-cell__bd">
                    <input type="text" class="weui-input" id="code" />
                </div>
                <div class="weui-cell__ft">
                    <a class="personal-btn1 fs07 cl-f js-verify">发送验证码</a>
                </div>
            </div>
            <div class="pic-btn">
                <p><a class="bg-b3 cl-f tan-qu" href="">取消</a></p>
                <p> <a class="bg-ff7 cl-f" id="binding">确定</a></p>
            </div>
        </div>
    </div>
    <!--编辑头像窗口-->
    <div class="personal-tou tan">
        <div class="bg-tan"></div>
        <div class="msui_nav msui_navTop">
            <a class="msui_navTop-back goBack" href="javascript:history.back();"><i class="micon-back"></i></a>
            <h1 class="msui_navTop-title">编辑头像</h1>
        </div>
        <div class="null">
            <div class="personal_img">
            	{if $info.img}
                <a><img class="personal_img2" id="newimg" src="{$info.img}" alt=""/></a>
                {else}
                <a><img class="personal_img2" id="newimg" src="/static/index/img/head.png" alt=""/></a>
                {/if}
            </div>
            <p class="cl-3333 text-center null1">编辑头像</p>
            <div class="pic-lf">
                <a>
                    <div class="fileInputContainer">
                          <input class="fileInput" type="file" class="myUpload" name="photos[]" accept="image/*" multiple id="subinfo" capture="camera"/>
                    </div>
                </a>
               <p>拍照</p>
            </div>
              <div class="pic-rt">
                <a>
                   <div class="fileInputtwo">
                        <input class="fileInput" type="file" id="tpinfo"/>
                    </div>
                </a>
                <p class="phone-title">相册</p>
               </div>
            <div class="pic-btn">
                <input type="hidden" id="imgsrc" value=""/>
                <p><a class="bg-b3 cl-f tan-qu">取消</a></p>
                <p> <a class="bg-ff7 cl-f" id="photoimg">上传</a></p>
            </div>
        </div>
    </div>
    <!--编辑背景图片窗口-->
    <div class="personal-bg tan">
        <div class="bg-tan"></div>
        <div class="msui_nav msui_navTop">
            <a class="msui_navTop-back goBack" href="javascript:history.back();"><i class="micon-back"></i></a>
            <h1 class="msui_navTop-title">编辑背景</h1>
        </div>
        <div class="null">
            <div class="personal_img">
                {if $info.user_back}
                <a><img class="personal_img2" id="newimg" src="{$info.user_back}" alt=""/></a>
                {else}
                <a><img class="personal_img2" id="newimg" src="/static/index/img/idx.png" alt=""/></a>
                {/if}
            </div>
            <p class="cl-3333 text-center null1">编辑背景</p>
            <div class="pic-lf">
                <a>
                    <div class="fileInputContainer">
                         <input class="fileInput" type="file" class="myUpload" name="photos[]" accept="image/*" multiple id="subinfos" capture="camera"/>
                    </div>
                </a>
                <p>拍照</p>
            </div>
            <div class="pic-rt">
                <a>
                    <div class="fileInputtwo">
                        <input class="fileInput" type="file" id="tpinfos"/>
                    </div>
                </a>

                <p>相册</p>
            </div>
            <div class="pic-btn">
                <p><a class="bg-b3 cl-f tan-qu" href="">取消</a></p>
                <p> <a class="bg-ff7 cl-f" id="backip">上传</a></p>
            </div>
        </div>
    </div>
</div>
<!-- jquery-2.1.4 -->
<script type="text/javascript" src="/static/index/jquery_weui/lib/jquery-2.1.4.js"></script>
<!-- jquery-weui.min.js -->
<script type="text/javascript" src="/static/index/jquery_weui/js/jquery-weui.min.js"></script>
<script src="/static/index/jquery_weui/js/swiper.min.js"></script>
<script>
	/*用户实名认证*/
	
	$("#user_rz").click(function(){
		var uid = {$id};
		var name = $("#name").val();
		var IDcard = $("#IDcard").val();
		var pic2 = $("#photo").val();
		
		$.post(
			"/index/personal/realname",
			{uid:uid,name:name,IDcard:IDcard,pic2:pic2},
		    function(data){
//		    	alert(data);return;
				if(data == '-1'){
					alert("姓名格式错误，请重新填写！");
				}else if(data == '-2'){
					alert("身份证号码错误，请重新填写！");
				}else if(data == '-3'){
					alert("请上传身份证照片!");
				}else if(data == '-4'){
					alert('请求认证失败，请查看数据是否填写完整！');
				}else{
					alert('请求提交 ,审核时间大概两个工作日完成！');
					location.href='/index/personal/personal?id='+uid
				}
		    }
		);
	});
	
    $("#subinfo").change(function (){
        var filess = this.files[0];
        var src=getObjectURL(filess);//获取上传文件的路径
        $("#newimg").attr("src",src);
        var formData = new FormData();
        formData.append("fb_img",this.files[0]);
        var url = "/index/Personal/mcupload";
        $.ajax({
            url:url,
            data:formData,
            processData: false,
            contentType: false,
            type:"post",
            success:function(data){
                 $("#imgsrc").val(data);
            },
            error:function(e){

            }
        });
    });
    $("#subinfos").change(function (){
        var filess = this.files[0];
        var src=getObjectURL(filess);//获取上传文件的路径
        $("#newimgs").attr("src",src);
        var formData = new FormData();
        formData.append("fb_img",this.files[0]);
        var url = "/index/Personal/mcupload";
        $.ajax({
            url:url,
            data:formData,
            processData: false,
            contentType: false,
            type:"post",
            success:function(data){
                $("#imgsrc").val(data);
            },
            error:function(e){

            }
        });
    });
    //编辑背景图
    $("#tpinfos").change(function(){
        var filess = this.files[0];
        var src=getObjectURL(filess);//获取上传文件的路径
        $("#newimgs").attr("src",src);
        var formData = new FormData();
        formData.append("fb_img",this.files[0]);
        var url = "/index/Personal/mcupload";
        $.ajax({
            url:url,
            data:formData,
            processData: false,
            contentType: false,
            type:"post",
            success:function(data){
                $("#imgsrc").val(data);
            },
            error:function(e){

            }
        });
    });
    //编辑头像
    $("#tpinfo").change(function(){
        var filess = this.files[0];
        var src=getObjectURL(filess);//获取上传文件的路径
        $("#newimg").attr("src",src);
        var formData = new FormData();
        formData.append("fb_img",this.files[0]);
        var url = "/index/Personal/mcupload";
        $.ajax({
            url:url,
            data:formData,
            processData: false,
            contentType: false,
            type:"post",
            success:function(data){
                $("#imgsrc").val(data);
            },
            error:function(e){

            }
        });
    });
    //图片上传
    $("#photoimg").click(function(){
        var img = $("#imgsrc").val();
        $.ajax({
            url:'/index/personal/uphead',
            type:'post',
            data:{img:img},
            success:function(data){
                if(data == "1") {
                    alert("头像修改成功");
                    window.location.href="/index/personal/personal?id="+{$user_id};
                }else if(data == "-1"){
                    alert("修改失败");
                }
            },
            error:function(){
alert("修改失败");
            }
        });
    });
    $("#backip").click(function(){
        var img = $("#imgsrc").val();
        $.ajax({
            url:'/index/personal/upback',
            type:'post',
            data:{img:img},
            success:function(data){
                if(data == "1") {
                    alert("背景修改成功");
                    window.location.href="/index/personal/personal?id="+{$user_id};
                }else if(data == "-1"){
                    alert("修改失败");
                }
            },
            error:function(){
                alert("修改失败");
            }
        });
    });
	
	/*绑定手机号码（发送验证码插件）*/
	function verifyCode(target,time,mtarget,message) {
        if (time == 0) {
            target.removeAttr('disabled');
            target.html('获取验证码');
            if (mtarget) {
                mtarget.closest('p').css('display', 'none');
                mtarget.html(message);
            }
        }
        else {
            target.attr('disabled', 'disabled');
            target.html(time + 's后可以重新获取');
            if (mtarget) {
                mtarget.closest('p').css('display', 'block');
                mtarget.html(message);
            }
            time--;
            setTimeout(function () {
                verifyCode(target, time);
            }, 1000)
        }
    }
    $('.js-verify').on('click',function(e){
    	/*验证手机号码*/
		var re;
	    var tel=$("#tel").val();
	    re= /^0?(13|14|15|17|18)[0-9]{9}$/
	    if(re.test(tel))
	    {
	    	$.post(
				"/index/binding/phone",
				{tel: tel},
			    function(data){
			    	if(data == -1){
			    		alert("该手机号码已被绑定！");
			    	}
		   		}
			);
	    	e.preventDefault();
       		verifyCode($(this),60);
	    }else{
	    	alert('请输入正确的手机号码！');
	    }
    });
    
    /*确认绑定*/
	$("#binding").click(function(){
		tel = $("#tel").val();
		code = $("#code").val();
		user_id = {$user_id};
		$.post(
			"/index/personal/binding",
			{ tel:tel,code:code,user_id:user_id},
		    function(data){
		    	if(data == 1){
		    		alert('绑定成功');window.location.href="/index/personal/personal?id="+user_id
		    	}
		    	if(data == -1){
		    		alert('该手机号码已被绑定！');
		    	}
		    	if(data == -3){
		    		alert('验证码错误！');
		    	}
		    	
		    }
		)
	});
	/*绑定邮箱*/
	$("#binding_email").click(function(){
		var re;
		email = $("#email_num").val();
		user_id = {$user_id};
		name = "{$info['name']}";
		re= /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/;
	    if(re.test(email))
		{
			$.post(
				"/index/email/send_email",
				{email:email,user_id:user_id,name:name},
			    function(data){
			    	if(data == -1){
			    		alert('该邮箱已经被绑定！');
			    	}else{
			    		alert('邮件发送成功，请前往邮箱查看！');
			    		window.location.href="/index/personal/personal?id="+user_id;
			    	}
			    }
			)
		}else{
	    	alert('您的电子邮件格式不正确！');
		}
	});
	
	$(function(){
		uid = {$user_id};
        
        $.post(
			"/index/personal/user_info",
			{id:uid},
		    function(data){
		    	obj = jQuery.parseJSON(data);
		    	if(obj.code == 1){
		    		name = obj.data.name;
		    		sex = obj.data.sex;
		    		age = obj.data.age;
		    		//姓名
		    		if(name != ""){
			    		$('#uname').parent().next('div').attr("class", "weui-icon-success-no-circle");
			    	}else{
			    		$('#uname').parent().next('div').attr("class", "weui-icon-warn");
			    	}
			    	//性别
			    	if(sex == 0 || sex == 1){
			    		$('#sex').parent().next('div').attr("class", "weui-icon-success-no-circle");
			    	}else{
			    		$('#sex').parent().next('div').attr("class", "weui-icon-warn");
			    	}
			    	//年龄
			    	if(age > 0){
			    		$('#age').parent().next('div').attr("class", "weui-icon-success-no-circle");
			    	}else{
			    		$('#age').parent().next('div').attr("class", "weui-icon-warn");
			    	}
		    	}
		    	$('#content').val('');
	   		}
		),'json';
	});
	
	/*修改姓名*/
	$("#uname").blur(function(){
        uname = $("#uname").val();
        uid = {$user_id};
        
       	$.post(
			"/index/personal/edit_uname",
			{uname:uname,id:uid},
		    function(data){
		    	if(data != ""){
		    		$('#uname').parent().next('div').attr("class", "weui-icon-success-no-circle");
		    	}else{
		    		$('#uname').parent().next('div').attr("class", "weui-icon-warn");
		    	}
		    }
		);
	});
	
	/*修改性别*/
	$("#sex").change(function(){
        sex = $("#sex").val();
        if(sex == '男'){
            sex = 1;
        }else if(sex == '女'){
            sex = 0;
        }else{
        	sex = '-1';
        }
        uid = {$user_id};
        
       	$.post(
			"/index/personal/edit_sex",
			{sex:sex,id:uid},
		    function(data){
		    	if(data == 0 || data == 1){
		    		$('#sex').parent().next('div').attr("class", "weui-icon-success-no-circle");
		    	}else{
		    		$('#sex').parent().next('div').attr("class", "weui-icon-warn");
		    	}
		    }
		);
	});
	
	/*修改年龄*/
	$("#age").blur(function(){
        age = $("#age").val();
        uid = {$user_id};
        
       	$.post(
			"/index/personal/edit_age",
			{age:age,id:uid},
		    function(data){
		    	if(data > 0){
		    		$('#age').parent().next('div').attr("class", "weui-icon-success-no-circle");
		    	}else{
		    		$('#age').parent().next('div').attr("class", "weui-icon-warn");
		    	}
		    }
		);
	});
	/*修改签名*/
	$("#qianmin").blur(function(){
        qian = $("#qianmin").val();
        uid = {$user_id};
        
       	$.post(
			"/index/personal/edit_qianmin",
			{qian:qian,id:uid},
		    function(data){
		    	if(data){
		    		alert('签名修改成功！');
		    	}
		    }
		);
	});
	
    $(".goBack").click(function (e) {
        e.preventDefault();
        $(this).parent().parent().hide(400)
    })
    $("#sex").select({
        title: "选择性别",
        items: ["未选择","男", "女"]
    });
    $("#personal-bg").click(function (e) {
        e.preventDefault();
        $(".personal-bg").show();
    })
    $("#personal-tou").click(function (e) {
        e.preventDefault();
        $(".personal-tou").show();
        var listImg=$('.personal-tou .personal_img2').css('width');
        $('.personal_img img').css('height',listImg);
        console.log(listImg)
    })
    $("#personal-email").click(function (e) {
        e.preventDefault();
        $(".personal-email").show();
    })
    $("#personal-phone").click(function (e) {
        e.preventDefault();
        $(".personal-phone").show();
    })
    $(".tan-qu").click(function (e) {
        e.preventDefault();
        $(this).parent().parent().parent().parent().hide(400)
    })
    $(".shiren-go").click(function (e) {
        e.preventDefault();
        $(".shiren").hide(400);
        $("#renzheng").show();
        $(".personal-list>div").removeClass("active1")
        $(".shiren").removeClass("active3")
        $(".index-tab>a").removeClass("active")
    })
    $("#renzheng-qu").click(function (e) {
        e.preventDefault();
        $("#renzheng").hide(400);
        $(".personal-list>div:first-child").addClass("active1")
        $(".index-tab>a:first-child").addClass("active")
    })
    $("#shiren").click(function (e) {
        e.preventDefault();
        $(".shiren").show();
    })
    $(".shiren-qu").click(function (e) {
        e.preventDefault();
        $(".shiren").hide(400);
    })
    $(function(){
        var perWidth = $(".personal_img1").css("width");
        $(".personal_img1").css("height",perWidth);
        personal();
        var swiper = new Swiper('.swiper-container', {
            slidesPerView: 3,
            spaceBetween: 5
        });
    })
    var topHeight=$('.top>img').height();
    var navHeight=$('.msui_nav.msui_navTop').height();
    var countHeight=topHeight+navHeight+12
    console.log(topHeight);
    
    $('.personal-list').css({
    	position:'absolute',
    	top:countHeight,
    	left:'0',
    	right:'0',
    	width:'100%'
    })
    $('.personal-list>div').css({
    	position:'fixed',
    	top:'0',
    	left:'100%',
    	right:'-100%'
    })
    $('.personal-list>div.active1').css({
    	position:'absolute',
    	top:'0',
    	left:'0',
    	right:'0'
    })
   var activeHeight=$('.activ1').height();
   console.log(activeHeight)
    $(".index-tab").on('click','a',function(e){
        e.preventDefault();
        $("#renzheng").hide(400);
        var count=$(this).attr('href');
        $(this).addClass('active')
                .siblings().removeClass('active');
        $(`[data-value='${count}']`).addClass("active1")
                .siblings().removeClass('active1');
                var activeHeight1=$('.activ1').height();
        $(`[data-value='${count}']`).css({
    	position:'absolute',
    	top:'0',
    	left:'0',
    	right:'0'
    }).siblings().css({
    	position:'fixed',
    	top:'0',
    	left:'100%',
    	right:'-100%'
    })
      
    })
    function personal(){
        for(var i=2;i<5;i++){
            var personalList=$(`.personal-list${i} .full`).children().length;
            if(personalList!==0){
                console.log(2);
                $(`.personal-list${i} .full`).addClass('active2')
                $(`.personal-list${i} .null`).removeClass('active2')
            }else{
                $(`.personal-list${i} .full`).removeClass('active2')
                $(`.personal-list${i} .null`).addClass('active2')
            }
        }
    }

    //上传图片
    $(function(){
        //点击上传时实时显示图片
        $(".sctp").on("change",".myUpload",function(){
            var src=getObjectURL(this.files[0]);//获取上传文件的路径
            $(this).siblings(".close").removeClass('hideimg');
            $(this).siblings(".addimg").addClass('hideimg');
            $(this).siblings(".showimg").removeClass('hideimg');
            $(this).siblings(".showimg").attr('src',src);//把路径赋值给img标签
            $(this).siblings(".addimg").remove();
        });

        //点击关闭按钮时恢复初始状态
        $(".close").on("click",function(){
            var file=$(this).parent().find(".myUpload");
            file.after(file.clone().val(""));
            file.remove();
            $(this).addClass('hideimg');
            $(this).siblings(".addimg").removeClass('hideimg');
            $(this).siblings(".showimg").addClass('hideimg');
            $(this).siblings(".showimg").removeAttr('src');//把img标签路径移除
        });
    });

    //获取上传文件的url
    function getObjectURL(file)
    {
        var url = null;
        if (window.createObjectURL != undefined)
        {
            url = window.createObjectURL(file);
        }
        else if (window.URL != undefined)
        {
            url = window.URL.createObjectURL(file);
        }
        else if (window.webkitURL != undefined)
        {
            url = window.webkitURL.createObjectURL(file);
        }
        return url;
    }
    $("#file").change(function(){
    	var filess = this.files[0];
        var formData = new FormData();
        formData.append("fb_img",this.files[0]);
        var url = "/index/Release/mcupload";
	$.ajax({
            url:url,
            data:formData,
            processData: false,
            contentType: false,
            type:"post",
            success:function(data){
                var photo = $("#photo").val();

                if(photo ==""){
                    photo = data;
                    $("#photo").val(photo);
                }else{
                    photo   = photo+"|"+data;
                    $("#photo").val("");
                    $("#photo").val(photo);
                }
            },
            error:function(e){

            }
        });

    });
$(function(){
		$('.personal-list .swiper-slide').each(function(){
			var swiperWidth=$(this).css('width');
			console.log(swiperWidth)
			$(this).css('height',swiperWidth)
		})
		
		
	
		//		图片处理
		$('.personal-list .swiper-slide>a img').each(function(){
			
			var imgWidth=-parseFloat($(this).css('width'))/2;
			var imgHeight=-parseFloat($(this).css('height'))/2;
			/*console.log(imgWidth)
			console.log(imgHeight)*/
			
			var imgWidth1=parseFloat($(this).css('width'));
			var imgHeight1=parseFloat($(this).css('height'));
			if(imgWidth1>=imgHeight1){
				$(this).css({
					height:'100%',
					width:'auto'
				})
			$(this).css('top','0')
			$(this).css('margin-left',imgWidth)
			}else if(imgWidth1<imgHeight1){
				$(this).css({
					height:'auto',
					width:'100%'
				})
				$(this).css('margin-top',imgHeight)
				$(this).css('margin-left',imgWidth)
			}
		})
	})

</script>
</body>
</html>

